package com.web;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.text.AbstractDocument.LeafElement;

import org.omg.CORBA.Request;

import model.LeaveDTO;
import model.LeaveDTO;
import model.UserDTO;
import bizlogic.LeaveManager;
import bizlogic.UserManager;

/**
 * @Thiri
 * Servlet implementation class ViewleaveApplication
 */
@WebServlet("/ViewleaveApplicationServlet")
public class ViewleaveApplicationServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private static final int data = 0;
	private int String;
	private int ArrayList;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ViewleaveApplicationServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doProcess(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doProcess(request, response);
	}
   
protected void doProcess(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	UserDTO us =(UserDTO)request.getSession().getAttribute("user");
	String id = us.getId().toString();
     //String id = request.getParameter("id"); 
	
     request.setAttribute("Id", id);
     
	LeaveManager lm=new LeaveManager();
	ArrayList<LeaveDTO> data = lm.findAllLeaveByManagerId(id);
	
    request.setAttribute("mgrId", data);
	RequestDispatcher rd = request.getRequestDispatcher("ViewLeaveApplication.jsp");
	rd.forward(request, response);
	
	
	
	}
}
